package string;

/* 
 * Author: rendy.jr
 * Date: Jun 10, 2011
 * 6.005 Elements of Software Construction
 * Rendy Bambang Junior
 * rendy.jr@gmail.com
 * 
 * Match class reponsible for matching word using left and right pattern
 * 
 */

public class Match {
	//return string after first left string
	public static String after(String source, String left){
		int x = source.indexOf(left);
		if(x==-1)
			return null;
		else
			return source.substring(x+left.length());
	}
	//return string before first right string	
	public static String before(String source, String right){
		int x = source.indexOf(right);
		if(x==-1)
			return null;
		else
			return source.substring(0,x-1);
	}
	//return string between left and right string
	public static String between(String source, String left, String right){
		String temp = after(source,left);
		if(temp!=null)
			return before(temp,right);
		else
			return null;
	}
}
